package lc20240627;

/**
 * @author 不知名帅哥
 * @version 1.0
 * @description 爬楼梯
 * @date 2024/6/28 0:03
 */
public class ClimbStairs {

    //本质上就是斐波那契数列
    public int climbStairs(int n) {
        int p = 0, q = 0, r = 1;
        for (int i = 1; i <= n; ++i) {
            p = q;
            q = r;
            r = p + q;
        }
        return r;
    }
    public static int getInt(int n){
        double v = Math.sqrt(5);
        double p1 = Math.pow((1 + v) / 2, n + 1);
        double p2 = Math.pow((1 - v) / 2, n + 1);

        int res= (int) ((p1-p2)/v);
        return res;
    }

    public static void main(String[] args) {
        System.out.println(getInt(10));
    }
}
